<template>
  <div class="mod-config">
      {{dataForm}}
    <el-card style="height: 40%;width: 100%">
      <div class="warp_l__34yS8">
          ♊&nbsp;&nbsp;<span class="work__00001">个人基本资料</span>
        </div>
      <!-- 弹窗, 新增 / 修改 -->
      <el-button type="text" size="small" @click="addOrUpdateHandle">修改</el-button>
      <el-form :inline="true" ref="dataForm" @keyup.enter.native="dataFormSubmit" label-width="80px">
        <!--  <el-form-item style="width: 60%">
          <img style="float:left;width:250px;height:135px;padding-right:20px" :src="dataForm.images" @click="uploadStatus=true"/>
        </el-form-item>-->
        <el-form-item style="width: 45%">
          <h3>姓名:{{dataForm.name}}</h3>
        </el-form-item>
        <el-form-item style="width: 45%">
          <span>性别：{{dataForm.sex}}</span>
        </el-form-item>
        <el-form-item  style="width: 45%">
          <span>生日：{{editDateTime(dataForm,dataForm.birthday)}}</span>
        </el-form-item>
        <el-form-item  style="width: 45%">
          <span>地址：{{editAddresstionId(dataForm.address)}}</span>
        </el-form-item>
        <el-form-item style="width: 45%">
          <span>手机号：{{dataForm.phone}}</span>
        </el-form-item>
        <el-form-item style="width: 45%">
          <span>邮箱：{{dataForm.email}}</span>
        </el-form-item>
        <el-form-item style="width: 45%">
          <span>工作时间：{{editDateTime(dataForm,dataForm.workTime)}}</span>
        </el-form-item>
      </el-form>
    </el-card>
    <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="refresh"></add-or-update>
  </div>
</template>

<script>
  import AddOrUpdate from './resumebasic-add-or-update'
  import moment from 'moment'
  export default {
    name:'resumebasic',
     inject:['reload'],
    data () {
      return {
        dataForm: {
          id: 0,
          name: '',
          sex: '',
          birthday: '',
          address: '',
          phone: '',
          images:'',
          email: '',
          resumeType: '',
          workTime: '',
          uid: '',
          clazzid:null,
          status:null,
          writeStatus:null
        },
        addOrUpdateVisible: false,
        user:{},
        addressOptionsOne: [],
        resumeId:null
        
      }
    },
    components: {
      AddOrUpdate
    },
   
    methods: {
      editDateTime(row,column){//日期格式处理
          const date = column
          if (date === undefined) {
              return ''
          }
          return moment(date).format('YYYY-MM-DD')
      },
      editAddresstionId(dataOne){
        if(dataOne!==''){
          let val = JSON.parse(dataOne);
          val = val[val.length-1];
          for (let i=0;i<this.addressOptionsOne.length;i++){
            let data = this.addressOptionsOne[i];
            if (data.id===val){
              return data.address;
            }
          }
        }
      },
       findAddressOptionsData(){
         this.$http({
          url: this.$http.adornUrl('/hope/address'),
          method: 'get'
        }).then(({data}) => {
          this.addressOptionsOne = data;
        })
      },
      // 根据登录用户uid获取简历基本数据列表
        findMyTraining () {
          this.resumeId = this.$route.query.resumeId
          //alert(this.resumeId+">>>>>>>>>>>>")
         
        // this.dataForm.id = localStorage.getItem('id')
       //this.user = JSON.parse(localStorage.getItem('user'));
        //this.dataForm.id=this.user.userId;
        // console.log(user);
       // this.visible = true
         this.$http({
              url: this.$http.adornUrl(`/resume/resumebasic/findResumeByUid`),
              method: 'get',
              params: this.$http.adornParams()
            }).then(({data}) => {
              if(data!==''){
                console.log('>>>>>>>>>>>>'+data);
                this.dataForm = data
                if(this.dataForm!=''){
                  this.$emit('resumTest')
                }
               
                localStorage.setItem("resume",JSON.stringify(data));
                this.writeStatus=1;
                localStorage.setItem("writeStatus",this.writeStatus);
              }else{
                this.writeStatus=0;
                localStorage.setItem("writeStatus",this.writeStatus);
              }
            })
        // this.$nextTick(() => {
        //   this.$refs['dataForm'].resetFields()
        //   if (this.dataForm.id) {
          
        //   }
        // }) 
      },
      // 新增 / 修改
      addOrUpdateHandle () {
        if(this.dataForm.uid==''){
          //this.dataForm.uid = this.user.userId;
          //this.dataForm.uid = this.user.userId;
          
        }
        this.addOrUpdateVisible = true
        this.$nextTick(() => {
          this.$refs.addOrUpdate.init(this.dataForm.uid)
        })
      },
      refresh () {
        this.reload()
      }
    },
    mounted(){
      this.findAddressOptionsData();
      this.findMyTraining();
      
    }
  }
</script>
